package com.example.pungolo.journal;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class MoodSelectionActivity extends Activity {

	private ImageView mood;
	private long longDate;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mood_selection);
    Intent caller = getIntent();
    int id=caller.getIntExtra("mood_id", -1);
    mood=(ImageView)findViewById(id);
    
    
    // add onClickListener to smileys
    
    addOnClickListenerToImageViews();
  }
  
  private void addOnClickListenerToImageViews(){
	  	
	  	ImageView angel=(ImageView)findViewById(R.id.moodUI_angel);
	    angel.setOnClickListener(new MoodOnClickListener(R.drawable.mood_angel));
	    
	    ImageView angry=(ImageView)findViewById(R.id.moodUI_angry);
	    angry.setOnClickListener(new MoodOnClickListener(R.drawable.mood_angry));
	    
	    ImageView big_smile=(ImageView)findViewById(R.id.moodUI_big_smile);
	    big_smile.setOnClickListener(new MoodOnClickListener(R.drawable.mood_happy));
	    
	    ImageView cool=(ImageView)findViewById(R.id.moodUI_cool);
	    cool.setOnClickListener(new MoodOnClickListener(R.drawable.mood_cool));
	    
	    ImageView crying=(ImageView)findViewById(R.id.moodUI_crying);
	    crying.setOnClickListener(new MoodOnClickListener(R.drawable.mood_crying));
	    
	    ImageView devil=(ImageView)findViewById(R.id.moodUI_devil);
	    devil.setOnClickListener(new MoodOnClickListener(R.drawable.mood_devil));
	    
	    ImageView embarassed=(ImageView)findViewById(R.id.moodUI_embarassed);
	    embarassed.setOnClickListener(new MoodOnClickListener(R.drawable.mood_embarassed));
	    
	    ImageView kiss=(ImageView)findViewById(R.id.moodUI_kiss);
	    kiss.setOnClickListener(new MoodOnClickListener(R.drawable.mood_kiss));
	    
	    ImageView laugh=(ImageView)findViewById(R.id.moodUI_laugh);
	    laugh.setOnClickListener(new MoodOnClickListener(R.drawable.mood_laugh));
	    
	    ImageView raspberry=(ImageView)findViewById(R.id.moodUI_raspberry);
	    raspberry.setOnClickListener(new MoodOnClickListener(R.drawable.mood_raspberry));
	    
	    ImageView sad=(ImageView)findViewById(R.id.moodUI_sad);
	    sad.setOnClickListener(new MoodOnClickListener(R.drawable.mood_sad));
	    
	    ImageView smirk=(ImageView)findViewById(R.id.moodUI_smirk);
	    smirk.setOnClickListener(new MoodOnClickListener(R.drawable.mood_smirk));
	    
	    ImageView surprise=(ImageView)findViewById(R.id.moodUI_surprise);
	    surprise.setOnClickListener(new MoodOnClickListener(R.drawable.mood_surprise));
	    
	    ImageView tired=(ImageView)findViewById(R.id.moodUI_tired);
	    tired.setOnClickListener(new MoodOnClickListener(R.drawable.mood_tired));
	    
	    ImageView uncertain=(ImageView)findViewById(R.id.moodUI_uncertain);
	    uncertain.setOnClickListener(new MoodOnClickListener(R.drawable.mood_uncertain));
	    
	    ImageView worried=(ImageView)findViewById(R.id.moodUI_worried);
	    worried.setOnClickListener(new MoodOnClickListener(R.drawable.mood_worried));
  }
  


  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.mood_selection, menu);
    return true;
  }
  
  
  public class MoodOnClickListener implements View.OnClickListener{
	  private int mood;
	  public MoodOnClickListener(int i){
		  super();
		  mood=i;
	  }
	  
  
	@Override
	public void onClick(View v) {
		Intent back = new Intent();
		  
		  if (mood<0)
			  setResult(RESULT_CANCELED,back);
		  else{
			  back.putExtra("mood_id", mood);
			  setResult(RESULT_OK,back);
		  }
		  
		  finish();
		
	}
  }
	  
  
  

}
